<template>
  <view>
    <keep-alive>
      <home
        :cur="PageCur"
        v-show="PageCur == 'home'"
        :key="commponent1Key"
      ></home>
    </keep-alive>
    <people v-show="PageCur == 'people'" :key="commponent2Key"></people>
    <event
      v-if="PageCur == 'event'"
      :key="commponent3Key"
      @click="handleClick"
    ></event>
    <view class="cu-bar tabbar bg-white shadow foot" style="z-index: 1000000">
      <view
        :class="PageCur == 'home' ? 'action text-green' : 'action text-gray'"
        @click="NavChange"
        data-cur="home"
      >
        <view class="cuIcon-homefill"></view>工作区
      </view>
      <view
        :class="PageCur == 'event' ? 'action text-green' : 'action text-gray'"
        @click="NavChange"
        data-cur="event"
      >
        <view class="cuIcon-list"></view>事件
      </view>
      <view
        :class="PageCur == 'people' ? 'action text-green' : 'action text-gray'"
        @click="NavChange"
        data-cur="people"
      >
        <view class="cuIcon-people"></view>个人中心
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      PageCur: "home",
      commponent1Key: 0,
      commponent2Key: 0,
      commponent3Key: 0,
    };
  },
  onLoad: function () {
    const paramValue = this.$route.query.value;
    if (paramValue) {
      this.PageCur = paramValue;
    }
    ++this.commponent2Key;
    ++this.commponent3Key;
  },
  methods: {
    NavChange: function (e) {
      this.PageCur = e.currentTarget.dataset.cur;
      if (this.PageCur === "home") {
        // ++this.commponent1Key;
      }
      if (this.PageCur === "event") {
        // 在这里可以根据条件来阻止点击事件的默认行为或者阻止事件冒泡
        uni.showLoading({
          title: "暂未开放！",
          mask: true,
        });
      } else {
        uni.hideLoading();
        // 处理点击事件的逻辑
      }
    },
  },
};
</script>

<style></style>
